package com.mvvmhabit.org.base

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter

/**
 * @Date: 2020/11/2 13:53
 * @Author:小妖
 * @Description:ViewPager 的 Fragment 的 adapter
 */
class BaseFragmentPagerAdapter(
    fm: FragmentManager,
    private val list: ArrayList<Fragment>,
    private val titles: ArrayList<String>
) : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

    override fun getItem(position: Int): Fragment = list[position]

    override fun getCount(): Int = list.size

    override fun getPageTitle(position: Int): CharSequence? {
        return titles[position]
    }
}